Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
Why am I getting a DOMException: "the operation is insecure" when adding a file to a drag&drop dataTransfer?

.. and what can I do about it?

Trying to add files to a drag event I came across a piece of documentation from Adobe showing how to add a file to event.dataTransfer.

I want to be able to generate the files contained in the dataTransfer so I tried this:

document.getElementById("draggable_element").addEventListener('dragstart', e => {
  e.dataTransfer.effectAllowed = "copy";
  e.dataTransfer.setData("application/x-moz-file",
    new File(["hello world"], "data.txt", {
      type: "text/plain",
      lastModified: new Date().getTime(),
    }));
});

(see this jsfiddle)

Unfortunately executing setData gives me a DOMException: the operation is insecure, without further explanation.

Googling and DuckDuckGoing gave me no results related to drag and drop so I have no clue what's going on and what I can do about it.

Is it possible to create files on the fly to append them to a drag&drop events dataTransfer? This answer suggests a way, but the context is totally different.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda